import os
from dotenv import load_dotenv
from datetime import timedelta

basedir = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
load_dotenv(os.path.join(basedir, '.env'))

class Config:
    SECRET_KEY = os.environ.get('SECRET_KEY')  # session密钥
    SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL')
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    MONGO_URI = os.environ.get('MONGO_URI')

    REMEMBER_COOKIE_DURATION = timedelta(days=7)  # 登录时记住我的cookie的有效期
    REMEMBER_COOKIE_REFRESH_EACH_REQUEST = True  # 滑动刷新过期时间

    CAPTCHA_RANGE = os.environ.get('CAPTCHA_RANGE')  # 验证码的随机取值范围
    FONT_PATH = os.path.join(basedir, 'app', 'static', 'MTCORSVA.TTF')  # 验证码字体

    MAIL_SERVER = os.environ.get('MAIL_SERVER')
    MAIL_PORT = 25
    MAIL_USE_TLS = True
    MAIL_USERNAME = os.environ.get('MAIL_USERNAME')
    MAIL_PASSWORD = os.environ.get('MAIL_PASSWORD')
    MAIL_DEFAULT_SENDER = os.environ.get('MAIL_DEFAULT_SENDER')
